#### left and right trolls, trained on both
pdf("figs/Figure1Top_FigureA1_conservative_mobilization_replicate_psrm.pdf", width=5.5, height=5.5)
par(mfrow=c(1,1), mar=c(6,3,2,2), mgp=c(4,1,0))
reference <- na.omit(with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),c(sorting2d, sorting2r)))
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    plot(
               y=rep(as.Date(tweet_date), 4), x=c(sorting2d, sorting2r, sorting2g, sorting2o), type="n",
        col="blue",
        bty="n",
        ylab="Tweet Month",
        xlab="\nConservative politics (-) vs Liberal politics (+)\n(scale in sd's)",
        ## ylim=the_ylim,
        lwd=3, cex.lab=1.3,
        main="",
        xlim=c(-1.75, 1.5),
        las=1,
        yaxt="n", xaxt="n"
    )
)
axis(1, seq(-1.5, 1.5, 0.5))
axis(
    2,
    seq(as.Date("2016-01-01"),as.Date("2016-11-01"), by="quarter"),
    labels=gsub(
        " ", "\n",
        as.yearmon(
            seq(as.Date("2016-01-01"),as.Date("2016-11-01"), by="quarter")
        )
    ),
    las=2
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2g,
    type="l",
        col="green3",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2r,
    type="l",
        col="red",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2o,
    type="l",
        col="orange",
        lwd=5
    )
)
##
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2d,
    type="l",
        col="blue",
        lwd=5
    )
)
abline(v=0, lwd=3, lty=2)
abline(v=c(-0.5, 0.5), lwd=1, lty=3)
##
legend(
    "bottomleft", bty="n",
    legend=c("Right troll", "Hashtag gamer", "Left Troll", "News Aggregator"),
    cex=0.8,
    col=c("red","green3","blue","orange"), lty=1, lwd=3,
    title="Categories:\nLinvill & Warren (2018)"
)
####
####
par(mfrow=c(1,1), mar=c(6,3,2,2), mgp=c(4,1,0))
reference <- na.omit(with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),c(sorting2d, sorting2r)))
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    plot(
               y=rep(as.Date(tweet_date), 4), x=c(sorting2d, sorting2r, sorting2g, sorting2o), type="n",
        col="blue",
        bty="n",
        ylab="Tweet Month",
        xlab="\n Conservative politics (-) vs Liberal politicals (+)\n(scale in sd's)",
        ## ylim=the_ylim,
        lwd=3, cex.lab=1.3,
        main="",
        xlim=c(-2.25, 1.5),
        las=1,
        yaxt="n", xaxt="n"
    )
)
axis(1, seq(-1.5, 1.5, 0.5))
axis(
    2,
    seq(as.Date("2016-01-01"),as.Date("2016-11-01"), by="quarter"),
    labels=gsub(
        " ", "\n",
        as.yearmon(
            seq(as.Date("2016-01-01"),as.Date("2016-11-01"), by="quarter")
        )
    ),
    las=2
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2g,
    type="l",
        col="green3",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2r,
    type="l",
        col="red",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2o,
    type="l",
        col="orange",
        lwd=5
    )
)
##
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2d,
    type="l",
        col="blue",
        lwd=5
    )
)
abline(v=0, lwd=3, lty=2)
abline(v=c(-0.5, 0.5), lwd=1, lty=3)
##
legend(
    "bottomleft", bty="n",
    legend=c("Right troll", "Hashtag gamer", "Left Troll", "News Aggregator", "Fearmonger","Unknown", "No label -- not in LW"),
    cex=0.8,
    col=c("red","green3","blue","orange","black","gray","pink"), lty=1, lwd=3,
    title="Categories:\nLinvill & Warren (2018)"
)

with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2fear,
    type="l",
        col="black",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2unknown,
    type="l",
        col="gray",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2nocategory,
    type="l",
        col="pink",
        lwd=5
    )
)
with(
    subset(
        aggregated_tweets,
        tweet_date >= "2016-01-01"
    ),
    lines(
        y=as.Date(tweet_date), x=sorting2commercial,
    type="l",
        col="yellow3",
        lwd=5
    )
)
dev.off()
